import {mapGetters} from 'vuex'
export default {
    data(){
        let auth = localStorage.getItem('auth') !== 'undefined' ? localStorage.getItem('auth') : '[]';
        return {
            localAuth: JSON.parse(auth) || []
        }
    },
    computed: {
        ...mapGetters(['auth'])
    },
    methods:{
        urlAvailible(url) {
            const auth =  this.auth && this.auth.button ? this.auth : this.localAuth;  // 先从store中获取权限信息保证是实时的，如果页面刷新则采用localstorage中的数据
            if(auth && auth.button){
                return auth.button.some(button=>{
                    return  url.indexOf(button.url) > -1
                })
            } else {
                return false
            }

        }
    }
}